package com.djf.getchatgptreq.controller;

import com.djf.getchatgptreq.entity.JsonTempl;
import com.djf.getchatgptreq.service.GptService;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


@RestController
public class getGptController {
    @Resource
    private GptService gptService;

    @PostMapping("/getGptService")
    public ResponseEntity<Object> getGptService(@RequestBody JsonTempl json){
        String result = null;
        try {
            result = gptService.getGptService(json.getCode());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return ResponseEntity.status(200).body(result);
    }
}
